package echo.service.impl;

import echo.service.OrderRepository;
import echo.service.OrderService;
import echo.vo.Item;
import echo.vo.Order;

import java.time.Clock;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单服务基础实现
 */
public abstract class BaseOrderService implements OrderService {
    protected final OrderRepository repository;
    protected final Clock systemClock; // 可用于真实环境时间获取

    public BaseOrderService(OrderRepository repository) {
        this.repository = repository;
        this.systemClock = Clock.systemDefaultZone();
    }
    // 真实环境使用的创建方法（自动获取当前时间）
    @Override
    public Order createOrder(List<Item> items, boolean isVIP) {
        return createOrder(items, isVIP, LocalDateTime.now(systemClock));
    }

    @Override
    public abstract Order createOrder(List<Item> items, boolean isVIP, LocalDateTime currentTime);


}





